package com.woniu.market_stall.mapper;

import com.woniu.market_stall.entity.Stall;
import com.woniu.market_stall.vo.AuctionStallVo;
import com.woniu.market_stall.vo.StallVo;
import com.woniu.market_stall.vo.UserVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StallMapper {
    int deleteByPrimaryKey(Integer stallId);

    int insert(Stall record);

    Stall selectByPrimaryKey(Integer stallId);

    List<Stall> selectAll();

    int updateByPrimaryKey(Stall record);

    List<StallVo> selectStallByCons(@Param(value = "status") String status , @Param(value = "mid") String marketId , @Param(value = "sname") String stallName);

    int insertStall(StallVo stallVo);


    int updateRentStallStatusAndTypeByStallId(@Param(value = "stallId") int stallId ,@Param(value = "userId") int userId);

    int updateActionStallStatusAndTypeByStallId(@Param(value = "stallId") int stallId ,@Param(value = "userId") int userId);

    //跟据摊位id查询所处市场id
    @Select("select market_id from stall where stall_id = #{value}")
    int selectMarketIdByStallId(int stallId);

    //查询所有未使用的摊位
    @Select("SELECT * from stall where status = 0 and is_delete = 0")
    List<Stall> selectAllUnUsedStall();

    int updateStallById(StallVo record);

    int deleteStallById(@Param(value = "stallId") int stallId);


    //竞拍的条件显示
    List<AuctionStallVo> selectAuctionStallByCons(@Param(value = "status") String status , @Param(value = "mid") String marketId , @Param(value = "sname") String stallName);


    //查询所有竞拍中的摊位
    @Select("select * from stall where status = 2 and is_delete = 0")
    List<Stall> selectAllAuctioningStall();


    void insertAuctionStall(AuctionStallVo auctionStallVo);

    //修改竞拍摊位信息
    void updateAuctionStallById(AuctionStallVo auctionStallVo);

    void deleteAuctionStallById(int id);

    @Select("select status from stall where stall_id = #{stallId}")
    int selectStallStatusById(int stallId);
}